//
//  SalesPromotionTableViewCell.m
//  AnXin100
//
//  Created by Sakura on 2018/10/30.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "SalesPromotionTableViewCell.h"

@interface SalesPromotionTableViewCell ()

@property (nonatomic, strong) UIView *backView;

@property (nonatomic, strong) UILabel *nameLabel;

@property (nonatomic, strong) UILabel *timeLabel;

@property (nonatomic, strong) UIImageView *productImage;

@property (nonatomic, strong) UIButton *buyBtn;

@end

@implementation SalesPromotionTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCell];
    }
    return self;
}

- (void)createCell {
    
    _backView = [UIView new];
    _backView.backgroundColor = [UIColor colorWithHex:0xF2F6D6];
    [self.contentView addSubview:_backView];
    
    _productImage = [UIImageView new];
    _productImage.image = [UIImage imageNamed:@"grape"];
    [_backView addSubview:_productImage];
    
    _nameLabel = [[UILabel alloc] init];
    _nameLabel.textColor = [UIColor colorWithHex:0xFF9E05];
    _nameLabel.font = [UIFont systemFontOfSize:16];
    [_backView addSubview:_nameLabel];
    _nameLabel.text = @"您关注的“云南无梓葡萄”降价啦！";
    
    _timeLabel = [UILabel new];
    _timeLabel.textColor = [UIColor colorWithHex:0xFF9E05];
    _timeLabel.font = [UIFont systemFontOfSize:15];
    [_backView addSubview:_timeLabel];
    _timeLabel.text = @"活动时间仅限今天";
    
    _buyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_buyBtn setTitle:@"立即抢购" forState:UIControlStateNormal];
    [_buyBtn setTitleColor:[UIColor colorWithHex:0xFF9E05] forState:UIControlStateNormal];
    _buyBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    _buyBtn.backgroundColor = [UIColor whiteColor];
    _buyBtn.layer.cornerRadius = 5;
    [_backView addSubview:_buyBtn];
}


- (void)layoutSubviews {
    [super layoutSubviews];
    _backView.sd_layout
    .topSpaceToView(self.contentView, 10)
    .leftSpaceToView(self.contentView, 10)
    .bottomSpaceToView(self.contentView, 10)
    .rightSpaceToView(self.contentView, 10);
    
    _productImage.sd_layout
    .topSpaceToView(_backView, 10)
    .bottomSpaceToView(_backView, 10)
    .rightSpaceToView(_backView, 20)
    .widthIs(100);
    
    _nameLabel.sd_layout
    .topSpaceToView(_backView, 15)
    .leftSpaceToView(_backView, 20)
    .rightSpaceToView(_productImage, 20)
    .heightIs(15);
    
    _timeLabel.sd_layout
    .topSpaceToView(_nameLabel, 8)
    .leftSpaceToView(_backView, 20)
    .rightSpaceToView(_productImage, 20)
    .heightIs(15);
    
    _buyBtn.sd_layout
    .widthIs(60)
    .heightIs(20)
    .leftSpaceToView(_backView, (SCREEN_WIDTH - 20) / 2 - 30)
    .bottomSpaceToView(_backView, 10);

}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}

@end
